package com.nageoffer.shortlink.project.dao.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.nageoffer.shortlink.project.dao.entity.LinkLocaleStatsDO;
import com.nageoffer.shortlink.project.dao.entity.LinkOsStatsDO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;

/**
 * ClassName: LinkOsStatsMapper
 * Package: com.nageoffer.shortlink.project.dao.mapper
 * Description:
 *
 * @Author Jetson
 * @Create 2024/10/29 15:17
 * @Version 1.0
 */
public interface LinkOsStatsMapper extends BaseMapper<LinkOsStatsDO> {
    @Insert("INSERT INTO t_link_os_stats (" +
            "        full_short_url,\n" +
            "        gid,\n" +
            "        date,\n" +
            "        cnt,\n" +
            "        os,\n" +
            "        create_time,\n" +
            "        update_time,\n" +
            "        del_flag)\n" +
            "VALUES (#{linkOsStats.fullShortUrl},\n" +
            "        #{linkOsStats.gid},\n" +
            "        #{linkOsStats.date},\n" +
            "        #{linkOsStats.cnt},\n" +
            "        #{linkOsStats.os},\n" +
            "        NOW(),\n" +
            "        NOW(),\n" +
            "        0)\n" +
            "ON DUPLICATE KEY\n" +
            "    UPDATE cnt  = cnt + #{linkOsStats.cnt};")
    void shortLinkOsState(@Param("linkOsStats") LinkOsStatsDO linkOsStatsDO);
}
